home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / PROGRAMS / CH4 / 4-1-4.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-09-19  |  1.9 KB  |  59 lines

  1. VERSION 5.00
  2. Begin VB.Form frmStates 
  3.    Caption         =   "State Demographics"
  4.    ClientHeight    =   1620
  5.    ClientLeft      =   1128
  6.    ClientTop       =   1632
  7.    ClientWidth     =   4884
  8.    BeginProperty Font 
  9.       Name            =   "MS Sans Serif"
  10.       Size            =   7.8
  11.       Charset         =   0
  12.       Weight          =   700
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    LinkTopic       =   "Form1"
  18.    PaletteMode     =   1  'UseZOrder
  19.    ScaleHeight     =   1620
  20.    ScaleWidth      =   4884
  21.    Begin VB.CommandButton cmdDisplay 
  22.       Caption         =   "Display Demographics"
  23.       Default         =   -1  'True
  24.       Height          =   495
  25.       Left            =   720
  26.       TabIndex        =   1
  27.       Top             =   240
  28.       Width           =   3375
  29.    End
  30.    Begin VB.PictureBox picDensity 
  31.       Height          =   495
  32.       Left            =   120
  33.       ScaleHeight     =   444
  34.       ScaleWidth      =   4524
  35.       TabIndex        =   0
  36.       Top             =   960
  37.       Width           =   4575
  38.    End
  39. Attribute VB_Name = "frmStates"
  40. Attribute VB_GlobalNameSpace = False
  41. Attribute VB_Creatable = False
  42. Attribute VB_PredeclaredId = True
  43. Attribute VB_Exposed = False
  44. Private Sub cmdDisplay_Click()
  45.   'Calculate the population densities of states
  46.   picDensity.Cls
  47.   Call CalculateDensity("Hawaii", 1184000, 6471)
  48.   Call CalculateDensity("Alaska", 607000, 591000)
  49. End Sub
  50. Private Sub CalculateDensity(state As String, pop As Single, area As Single)
  51.   Dim rawDensity As Single, density As Single
  52.   'The density (number of people per square mile)
  53.   'will be displayed rounded to a whole number
  54.   rawDensity = pop / area
  55.   density = Round(rawDensity)         'round to whole number
  56.   picDensity.Print "The density of "; state; " is"; density;
  57.   picDensity.Print "people per square mile."
  58. End Sub
  59.